﻿using System.Collections;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

namespace CoreModule.Converters
{
    /// <summary>
    /// 没有使用
    /// </summary>
    public class StringToSolidColorBrushConverter : IValueConverter
    {

        /// <summary>
        /// 
        /// </summary>
        private List<string> _values = new List<string>();
        public IList Values => _values;
        /// <summary>
        /// 
        /// </summary>
        public bool IsNullOrWhiteSpace { get; set; } = true;

        /// <summary>
        /// #81848F
        /// </summary>
        public System.Windows.Media.Color EmptyColor { get; set; } = System.Windows.Media.Color.FromRgb(0x81, 0x84, 0x8F);

        public System.Windows.Media.Color DefaultColor { get; set; } = System.Windows.Media.Colors.Black;

    
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            
            if (IsNullOrWhiteSpace)
            {
                if(string.IsNullOrWhiteSpace(value+""))
                {
                    return new SolidColorBrush(EmptyColor);
                }
            }

           if ( Values.Contains(value+""))
            {
                return new SolidColorBrush(EmptyColor);
            }
           return new SolidColorBrush(DefaultColor);

        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
